/*
 * @(#)IgnoreBindingMarshalingView.java
 *
 * Copyright 2011 Xinhua Online, Inc. All rights reserved.
 */

package com.winxuan.channel.support;

import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;

import javax.servlet.ServletException;

import org.springframework.validation.BindingResult;
import org.springframework.web.servlet.view.xml.MarshallingView;

/**
 * description
 * @author  liuan
 * @version 1.0,2011-2-22
 */
public class IgnoreBindingMarshalingView extends MarshallingView{
	
	@Override
	protected Object locateToBeMarshalled(Map model) throws ServletException {
		Map newModel=new HashMap();
		if (model != null && !model.isEmpty()) {
			Iterator it=model.keySet().iterator();
			while(it.hasNext()){
				Object key=it.next();
				Object value=model.get(key);
				if(!(value instanceof BindingResult))
					newModel.put(key, value);
			}
		}
		return super.locateToBeMarshalled(newModel);
	}
	
}
